package com.example.figurehecheng.controller.merchant;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.figurehecheng.common.constant.MessageConstant;
import com.example.figurehecheng.common.context.BaseContext;
import com.example.figurehecheng.common.exception.AccountExist;
import com.example.figurehecheng.common.result.PageResult;
import com.example.figurehecheng.common.result.Result;
import com.example.figurehecheng.domain.dto.FoodDTO;
import com.example.figurehecheng.domain.dto.FoodtypeDTO;
import com.example.figurehecheng.domain.entity.Foodtype;
import com.example.figurehecheng.service.IFoodtypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 宇科工作室
 * @since 2024-10-18
 */
@RestController("merchantFoodtypeController")
@RequestMapping("/merchant/foodtype")
@CrossOrigin
@Api("菜品分类")
@Slf4j
@RequiredArgsConstructor
public class FoodtypeController {
    private final IFoodtypeService ifoodtypeService;


    /**
     * 获取所有分类名称
     * @return
     */
    @GetMapping("/getFoodType")
    @ApiOperation("获取所有分类名称")
    public Result<List> getFoodType(){
        return Result.success(ifoodtypeService.list(new QueryWrapper<Foodtype>()
                .eq("canteen_id", BaseContext.getCurrentId())));
    }

    /**
     * 获取所有菜品信息
     */
    @GetMapping("/getDishtypeAll")
    @ApiOperation("获取所有分类名称")
    public Result<PageResult> getDishtypeAll(
            @RequestParam(value = "name",required = false)String name,
            @RequestParam(value = "pageNum")Integer pageNum,
            @RequestParam(value = "pageSize")Integer pageSize){
        PageResult dishAll = ifoodtypeService.getDishtypeAll(name, pageNum, pageSize);
        return Result.success(dishAll);
    }



    //修改

    @PostMapping("/updateDish")
    @ApiOperation("修改菜品信息")
    public Result updateDish(@RequestBody FoodtypeDTO foodtypeDto) {
        ifoodtypeService.updateDish(foodtypeDto);
        return Result.success();
    }

    /**
     * 删除关信息
     */
    @DeleteMapping("/deleteDish")
    @ApiOperation("删除菜品相关信息")
    public void deleteDish(@RequestBody FoodtypeDTO foodtypeDto){
        ifoodtypeService.deleteDish(foodtypeDto);
    }

    /**
     * 新增分类
     * @param
     */
    @PostMapping("/addDish")
    @ApiOperation("添加菜品")
    public void addDish(@RequestBody FoodtypeDTO foodtypeDto){
        ifoodtypeService.addDish(foodtypeDto);
    }



















}
